package 课程设计报告_hb_7_8;

/**
 * @author Jiang Zhiyan
 *
 * 2021年7月8日 上午9:13:22
 *
 */
public class DrawMoneyThread extends Thread{
   private Account account;
   private double money;
   
/**
 * @param account
 * @param money
 */
public DrawMoneyThread(String name,Account account, double money) {
	super(name);
	this.account = account;
	this.money = money;
}
 
@Override
	public void run() {
//	account称为同步监视器
	  synchronized (account) {
		  try {
				Thread.sleep(2);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			System.out.println(Thread.currentThread().getName());
			account.drawMoney(money);
		}
	}	
	

}
